class ChatModel {
  String token;
  String userName;
  String userHead;
  int readCount;
  List<Msglist> msglist;

  ChatModel({this.token, this.userName, this.userHead, this.readCount = 0, this.msglist});

  ChatModel.fromJson(Map<String, dynamic> json) {
    token = json['token'];
    userName = json['userName'];
    userHead = json['userHead'];
    readCount = json['readCount'] ?? 0;
    if (json['msglist'] != null) {
      msglist = new List<Msglist>();
      json['msglist'].forEach((v) {
        msglist.add(new Msglist.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['token'] = this.token;
    data['userName'] = this.userName;
    data['userHead'] = this.userHead;
    data['readCount'] = this.readCount ?? 0;
    if (this.msglist != null) {
      data['msglist'] = this.msglist.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Msglist {
  String token;
  String userToken; // 我方token
  String message;
  int type;
  String userName; // 对方昵称
  String userHead; // 对方头像
  int isread;
  int createtime;
  String label;

  Msglist(
      {this.token,
      this.userToken,
      this.message,
      this.type,
      this.userName,
      this.userHead,
      this.isread,
      this.createtime,
      this.label});

  Msglist.fromJson(Map<String, dynamic> json) {
    token = json['token'];
    userToken = json['userToken'];
    message = json['message'];
    type = json['type'];
    userName = json['userName'];
    userHead = json['userHead'];
    isread = json['isread'];
    createtime = json['createtime'];
    label = json['label'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['token'] = this.token;
    data['userToken'] = this.userToken;
    data['message'] = this.message;
    data['type'] = this.type;
    data['userName'] = this.userName;
    data['userHead'] = this.userHead;
    data['isread'] = this.isread;
    data['createtime'] = this.createtime;
    data['label'] = this.label;
    return data;
  }
}
